FROM python:3.12.0-alpine

WORKDIR /usr/src/app

# Prevents Python from writing pyc files to disc
ENV PYTHONDONTWRITEBYTECODE 1
# Prevents Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /usr/src/app/requirements.txt

# Install dependencies
RUN set -eux \
    && apk add --no-cache --virtual .build-deps build-base \
        openssl-dev libffi-dev gcc musl-dev python3-dev \
        bash \
    && pip install --upgrade pip setuptools wheel \
    && pip install -r /usr/src/app/requirements.txt \
    && rm -rf /root/.cache/pip

# Copy application code
COPY . /usr/src/app/